#ifndef AVALON_CODEDWRITER_HPP
#define AVALON_CODEDWRITER_HPP
#include "Avalon/Base/Handle.hpp"
#include "Avalon/Codecs/Codecs.hpp"
#include "Avalon/IO/Writer.hpp"

namespace Avalon {
namespace Codecs {

  /*! \class CodedWriter
   *  \brief Writes coded data using a Decoder.
   */
  class CodedWriter : public IO::Writer {
    public:

      //! Creates a CodedWriter.
      /*!
        \param destination The destination to write to.
        \param encoder The Encoder to use.
      */
      CodedWriter(Carry<IO::Writer> destination, Encoder* encoder);

      virtual ~CodedWriter();

      virtual void Write(const void* data, int size,
        Out<Threading::Async<void> > result);

      virtual void Write(const IO::Buffer& data,
        Out<Threading::Async<void> > result);

    private:
      Handle<IO::Writer> m_destination;
      boost::scoped_ptr<Encoder> m_encoder;
  };
}
}

#endif // AVALON_CODEDWRITER_HPP
